import com.jfinal.weixin.sdk.api.RedPackApi;
import com.jfinal.weixin.sdk.kit.PaymentKit;
import com.lsk.util.*;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2018-11-21.
 */
public class 服务商发红包 {
    public static void main(String[] strings){
        Map<String, String> params=new HashMap<>();
        String mch_id="1516301251";
        String payKey="de28ffc5b3e04fc1bd72b0d3b9c0c40a";
        String id=System.currentTimeMillis()+ Tools.getRandomNum()+"";
        String apiclientPath= GlobalParameter.apiclientPath
                +mch_id+"/apiclient_cert.p12";
        String xmlResult="";
        params.put("nonce_str", UtilUUID.getUUID());
        params.put("mch_billno",id);
        params.put("mch_id",mch_id);
        params.put("sub_mch_id","1518607171");
        params.put("msgappid","wxfb9d70c28984bdca");
        //params.put("consume_mch_id","1518607171");
        params.put("wxappid","wxc5d915fb6c65cd17");
        params.put("send_name","红包名称");
        params.put("re_openid","oNFtj5xlHvTdwcXyW_Oxtxl_CwF0");
        params.put("total_amount","101");
        params.put("total_num","1");
        params.put("wishing","红包祝福语");//红包祝福语
        params.put("client_ip","127.0.0.1");
        params.put("act_name","测试");
        params.put("remark","测试");
        String sign= PaymentKit.createSign(params,payKey);
        params.put("sign",sign);
        Syslog.info("发送红包参数params:"+ JsonUtil.getJsonStr(params));
        xmlResult= RedPackApi.sendRedPack(params,apiclientPath,mch_id);
        Map<String, String> resultXML = PaymentKit.xmlToMap(xmlResult);
        Syslog.info(resultXML);
    }
}
